from dotenv import load_dotenv
from langchain import hub
from langchain.agents import AgentExecutor, create_tool_calling_agent, create_openai_tools_agent
from langchain.chat_models import init_chat_model
from src.Basic.tools.browser import get_browser

load_dotenv(override=True)

#定义模型
model = init_chat_model(model="deepseek-chat", model_provider="deepseek")
# 定义 天气查询 工具函数
tools = get_browser()
prompt = hub.pull("hwchase17/openai-tools-agent")
agent = create_tool_calling_agent(llm=model,tools=tools,prompt=prompt)
# agent = create_openai_tools_agent(llm=model,tools=tools,prompt=prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)

while True:
    query = input("请问我可以帮您做什么吗？")
    if query == "exit" or query == "quit" or query == "bye" or query == "goodbye" or query == "stop":
        break
    #并行
    response = agent_executor.invoke({"input": query})
    print(response['output'])